<?php
/* SVN FILE: $Id: starter.php 255 2009-12-22 06:45:47Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* Admin Plugin Ajax
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 255 $
* @lastrevision $Date: 2009-12-22 06:45:47 +0000 (Tue, 22 Dec 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-12-22 06:45:47 +0000 (Tue, 22 Dec 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/plugins/bank/publicAjax/starter.php $
*/

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
	exit();
}

class plugin_ajax_public_bank_starter extends ipsAjaxCommand
{
	/**
	 * Class entry point
	 *
	 * @access	public
	 * @param	object		Registry reference
	 * @return	void		[Outputs for the ajax handler]
	 */
	public function doExecute( ipsRegistry $registry ) 
	{
		if(!marketRegistry::hasPluginPermission('view'))
		{
			$this->returnJsonError( 'nopermission' );
		}
		
		if(!isset($this->caches['ibm_bank_starter'][$this->request['starter_id']]))
		{
			$this->returnJsonError( 'nopermission' );
		}
		
		$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_market', 'bank_bank' ) );
		
		$starter = $this->caches['ibm_bank_starter'][$this->request['starter_id']];
		$starter['description'] = IPSText::getTextClass('bbcode')->preDisplayParse($starter['s_description']);
		$starter['create_fee'] = marketFormatter::formatCurrency(numbers::multiply($starter['create_price'],$this->memberData['market_deduct']));
		$starter['interest_time'] = sprintf($this->lang->words['every_x'], marketFormatter::relativeTimeFull($starter['s_interest_time'], 'LONG'));
		$starter['interest_rate'] = marketFormatter::numberFormat($starter['s_interest_rate'], 5, false)."%";
		$starter['deposit_fee'] = marketFormatter::numberFormat($starter['s_deposit_fee'], 5, false)."%";
		$starter['withdraw_fee'] = marketFormatter::numberFormat($starter['s_withdraw_fee'], 5, false)."%";
		$starter['remove_fee'] = marketFormatter::formatCurrency(numbers::multiply($starter['delete_fee'],$this->memberData['market_deduct']));
		
		$this->returnJsonArray( $starter );
	}
}